package it.fantacalcio.utility;

public class Utility {
	
	public static Integer parsFromStringInt(String s){
		try{
			if(s==null){
				return null;
			}
			int x=Integer.parseInt(s);
			return x;
		}
		catch(NumberFormatException exc){
			return null;
		}
	}
	
	public static String md5hash(String password) {
        String hashString = null;
        try {
            java.security.MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
            byte[] hash = digest.digest(password.getBytes());
            hashString = "";
            for (int i = 0; i < hash.length; i++) {
                hashString += Integer.toHexString( 
                                  (hash[i] & 0xFF) | 0x100 
                              ).toLowerCase().substring(1,3);
            }
        } catch (java.security.NoSuchAlgorithmException e) {
            System.out.println(e);
        }
        return hashString;
    }
}
